<%@ page import="com.lu.entity.NewsUsers" %>
<%@ page import="java.util.List" %>
<%@ include file="checkLogin.jsp"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%--
  Created by IntelliJ IDEA.
  User: l
  Date: 2022/5/26
  Time: 17:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false"  %>
<!DOCTYPE>
<html>
<head>
    <title>管理后台</title>
    <link href="./css/admin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="header">
    <div id="welcome">欢迎使用新闻管理系统！</div>
    <div id="nav">
        <div id="logo"><img src="./images/logo.jpg" alt="新闻中国" /></div>
        <div id="a_b01"><img src="./images/a_b01.gif" alt="" /></div>
    </div>
</div>
<div id="admin_bar">
    <div id="status">
        管理员：${currentUser.uname} 登录 &#160;&#160;&#160;&#160;
        <a href="logout.jsp">login out</a>
        当前在线的有${fn:length(currentUserList)} 个人:
        <c:forEach var="newsUsers" items="${currentUserList}">
            <a href="#">${newsUsers.uname}</a>
        </c:forEach>
    </div>
    <div id="channel"> </div>
</div>
<div id="main">
    <div id="opt_list">
        <ul>
            <li><a href="news_add.jsp">添加新闻</a></li>
            <li><a href="#">编辑新闻</a></li>
            <li><a href="#">查找新闻</a></li>
            <li><a href="topic_add.jsp">添加主题</a></li>
            <li><a href="topicList.jsp">编辑主题</a></li>
            <li><a href="productList.jsp">购买商品</a></li>
            <li><a href="updateUser.jsp">修改个人资料</a></li>
        </ul>
    </div>
    <div id="opt_area">
        <script src="./js/jquery-3.6.0.js"></script>
        <script>
            $(function () {
                let flag = false;
                $("#tname").blur(function (){
                    let $tname = $(this).val();
                    let $span = $(this).next("span");
                    if($tname == ""){
                        $span.html("主题不能为空!");
                        flag = false;
                        return;
                    }
                    $.ajax({
                        url:"GetOneTopicByTnameServlet",
                        type:"post",
                        data:{"tname":$tname},
                        dataType:"text",
                        success:function (data){
                            if(data=="true"){
                                $span.html("");
                                flag = true;
                            }else{
                                $span.html("该主题已存在!");
                                flag = false;
                            }
                        },
                        error:function () {
                            alert("读取错误!");
                            flag = false;
                        }
                    })
                });


                $("#form1").submit(function () {
                    if(flag==false){
                        return false;
                    }
                })
            })
        </script>
        <ul>
            <h3>添加主题</h3>
            <form id="form1" action="AddTopicServlet" method="post">
                <p>
                    主题名称: <input type="text" name="tname" id="tname"><span></span>
                </p>
                <input type="submit" value="提交">
                <input type="reset" value="重置">
            </form>
        </ul>
    </div>
</div>
<div id="site_link">
    <a href="">关于我们</a><span>|</span>
    <a href="">Aboue Us</a><span>|</span>
    <a href="">联系我们</a><span>|</span>
    <a href="">广告服务</a><span>|</span>
    <a href="">供稿服务</a><span>|</span>
    <a href="">法律声明</a><span>|</span>
    <a href="">招聘信息</a><span>|</span>
    <a href="">网站地图</a><span>|</span>
    <a href="">留言反馈</a>
</div>
</body>
</html>
